﻿using Gap.Bll;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Gap.Bll.BritishGas;

namespace Gap.BllTest
{
    
    
    /// <summary>
    ///This is a test class for BritishGasHabitTest and is intended
    ///to contain all BritishGasHabitTest Unit Tests
    ///</summary>
    [TestClass()]
    public class BritishGasHabitTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Get
        ///</summary>
        [TestMethod()]
        public void GetTest()
        {
            string schoolId = "TestSchool01";
            string className = "ClassA1";
            DateTime start = DateTime.Now.AddMonths(-1);
            DateTime end = DateTime.Now;
            Habits actual;

            actual = Habits.Get(schoolId, className, start, end);
            
            Assert.IsNull(actual);

            actual = Habits.CreateInstance(schoolId, className, start, end);
            Assert.IsNotNull(actual);

            Assert.AreEqual(schoolId, actual.SchoolId);
            Assert.AreEqual(className, actual.ClassName);
            Assert.AreEqual(new DateTime(start.Year, start.Month, start.Day), actual.Start);
            Assert.AreEqual(new DateTime(end.Year, end.Month, end.Day), actual.End);

        }

        [TestMethod]
        public void InsertTest()
        {
            string schoolId = "TestSchool01";
            string className = "ClassA1";
            DateTime start = DateTime.Today.AddMonths(-1);
            DateTime end = DateTime.Today;
            Habits actual;

            actual = Habits.Get(schoolId, className, start, end);

            if (actual != null)
            {
                actual.Delete();
            }

            actual = Habits.CreateInstance(schoolId, className, start, end);

            Assert.AreEqual(0, actual.Id);

            actual.ComputersLeftOn = 1;
            actual.ComputersTotal = 2;
            actual.DeskLampsLeftOn = 3;
            actual.DeskLampsTotal = 4;
            actual.DVDsLeftOn = 5;
            actual.DVDsTotal = 6;
            actual.LightBulbsLeftOn = 7;
            actual.LightBulbsTotal = 8;
            actual.MonitorsLeftOn = 9;
            actual.MonitorsTotal = 10;
            actual.PrintersLeftOn = 11;
            actual.PrintersTotal = 12;
            actual.TelevisionsLeftOn = 13;
            actual.TelevisionsTotal = 14;
            actual.WhiteBoardsLeftOn = 15;
            actual.WhiteBoardsTotal = 16;
            actual.SickRoomAverage = 17.123f;
	        actual.ClassRoomAverage = 18.123f;
	        actual.HallsAverage = 19.123f;
	        actual.WaterAverage = 20.123f;
	        actual.HeatingOn = true;
	        actual.WindowsTotal = 21;
        	actual.WindowsOpen = 22;
	        actual.InternalDoorsTotal = 23;
	        actual.InternalDoorsOpen = 24;
	        actual.ExternalDoorsTotal = 25;
	        actual.ExternalDoorsOpen = 26;
	        actual.RadiatorsTotal = 27;
            actual.RadiatorsObstructed = 28;

            actual.Update();

            Assert.AreNotEqual(0, actual.Id);
            Assert.AreEqual(schoolId, actual.SchoolId);
            Assert.AreEqual(className, actual.ClassName);
            Assert.AreEqual(start, actual.Start);
            Assert.AreEqual(end, actual.End);

            Assert.AreEqual(1, actual.ComputersLeftOn);
            Assert.AreEqual(2, actual.ComputersTotal);
            Assert.AreEqual(3, actual.DeskLampsLeftOn);
            Assert.AreEqual(4, actual.DeskLampsTotal);
            Assert.AreEqual(5, actual.DVDsLeftOn);
            Assert.AreEqual(6, actual.DVDsTotal);
            Assert.AreEqual(7, actual.LightBulbsLeftOn );
            Assert.AreEqual(8, actual.LightBulbsTotal );
            Assert.AreEqual(9, actual.MonitorsLeftOn );
            Assert.AreEqual(10, actual.MonitorsTotal );
            Assert.AreEqual(11, actual.PrintersLeftOn);
            Assert.AreEqual(12, actual.PrintersTotal);
            Assert.AreEqual(13, actual.TelevisionsLeftOn);
            Assert.AreEqual(14, actual.TelevisionsTotal );
            Assert.AreEqual(15, actual.WhiteBoardsLeftOn );
            Assert.AreEqual(16, actual.WhiteBoardsTotal);
            Assert.AreEqual(17.123f, actual.SickRoomAverage);
            Assert.AreEqual(18.123f, actual.ClassRoomAverage);
            Assert.AreEqual(19.123f, actual.HallsAverage);
            Assert.AreEqual(20.123f, actual.WaterAverage);
            Assert.AreEqual(true, actual.HeatingOn);
            Assert.AreEqual(21, actual.WindowsTotal);
            Assert.AreEqual(22, actual.WindowsOpen);
            Assert.AreEqual(23, actual.InternalDoorsTotal);
            Assert.AreEqual(24, actual.InternalDoorsOpen);
            Assert.AreEqual(25, actual.ExternalDoorsTotal);
            Assert.AreEqual(26, actual.ExternalDoorsOpen);
            Assert.AreEqual(27, actual.RadiatorsTotal);
            Assert.AreEqual(28, actual.RadiatorsObstructed);

            actual.ComputersLeftOn = null;
            actual.ComputersTotal = null;
            actual.DeskLampsLeftOn = null;
            actual.DeskLampsTotal = null;
            actual.DVDsLeftOn = null;
            actual.DVDsTotal = null;
            actual.LightBulbsLeftOn = null;
            actual.LightBulbsTotal = null;
            actual.MonitorsLeftOn = null;
            actual.MonitorsTotal = null;
            actual.PrintersLeftOn = null;
            actual.PrintersTotal = null;
            actual.TelevisionsLeftOn = null;
            actual.TelevisionsTotal = null;
            actual.WhiteBoardsLeftOn = null;
            actual.WhiteBoardsTotal = null;
            actual.SickRoomAverage = null;
            actual.ClassRoomAverage = null;
            actual.HallsAverage = null;
            actual.WaterAverage = null;
            actual.HeatingOn = false;
            actual.WindowsTotal = null;
            actual.WindowsOpen = null;
            actual.InternalDoorsTotal = null;
            actual.InternalDoorsOpen = null;
            actual.ExternalDoorsTotal = null;
            actual.ExternalDoorsOpen = null;
            actual.RadiatorsTotal = null;
            actual.RadiatorsObstructed = null;

            actual.Update();

            Assert.IsNull(actual.ComputersLeftOn);
            Assert.IsNull(actual.ComputersTotal);
            Assert.IsNull(actual.DeskLampsLeftOn);
            Assert.IsNull(actual.DeskLampsTotal);
            Assert.IsNull(actual.DVDsLeftOn);
            Assert.IsNull(actual.DVDsTotal);
            Assert.IsNull(actual.LightBulbsLeftOn);
            Assert.IsNull(actual.LightBulbsTotal);
            Assert.IsNull(actual.MonitorsLeftOn);
            Assert.IsNull(actual.MonitorsTotal);
            Assert.IsNull(actual.PrintersLeftOn);
            Assert.IsNull(actual.PrintersTotal);
            Assert.IsNull(actual.TelevisionsLeftOn);
            Assert.IsNull(actual.TelevisionsTotal);
            Assert.IsNull(actual.WhiteBoardsLeftOn);
            Assert.IsNull(actual.WhiteBoardsTotal);
            Assert.IsNull(actual.SickRoomAverage);
            Assert.IsNull(actual.ClassRoomAverage);
            Assert.IsNull(actual.HallsAverage);
            Assert.IsNull(actual.WaterAverage);
            Assert.IsFalse(actual.HeatingOn);
            Assert.IsNull(actual.WindowsTotal);
            Assert.IsNull(actual.WindowsOpen);
            Assert.IsNull(actual.InternalDoorsTotal);
            Assert.IsNull(actual.InternalDoorsOpen);
            Assert.IsNull(actual.ExternalDoorsTotal);
            Assert.IsNull(actual.ExternalDoorsOpen);
            Assert.IsNull(actual.RadiatorsTotal);
            Assert.IsNull(actual.RadiatorsObstructed);

            actual.Delete();
        }


    }
}
